﻿package com.shuqi.bookbag;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.shuqi.common.utils.Log4an;

/**
 * 书包相关数据库类
 * @author yanghuawei
 * 
 */
public class SDDatabase extends SDSQLiteOpenHelper {

    private static final String TAG = "yhw_SDDatebase";

    private final static int DATABASE_VERSION = 2;
    public final static String DATABASE_NAME = "sqsddata.db";
    private static SDDatabase sdDatabase;

    public static synchronized SDDatabase getInstance(Context context) {
        if (sdDatabase == null) {
            sdDatabase = new SDDatabase(context.getApplicationContext());
        }
        return sdDatabase;
    }

    private SDDatabase(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log4an.d(TAG, "create SD卡数据库");
        db.execSQL(TABLE_SDCARD_SHUBAO);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    /**
     * 书包表
     */
    public static final String TABLE_SDCARD_SHUBAO = "create table if not exists book_bag(" //
            + "id integer primary key," //
            + "bag_name varchar," //
            + "file_name varchar," //
            + "book_name varchar," //
            + "book_id varchar," //
            + "author varchar," //
            + "url varchar," //
            + "package_id varchar," //
            + "file_size varchar," //
            + "flag varchar," //
            + "create_time int64," //
            + "isdownloaded varchar," //
            + "account varchar)";
}
